package com.ruoyi.doctor.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.doctor.domain.DoctorRegister;
import com.ruoyi.doctor.mapper.DoctorRegisterMapper;
import com.ruoyi.doctor.service.DoctorRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 挂号Service业务层处理
 *
 * @author ruoyi
 * @date 2022-11-14
 */
@Service
public class DoctorRegisterServiceImpl implements DoctorRegisterService
{
    @Autowired
    private DoctorRegisterMapper doctorRegisterMapper;

    /**
     * 查询挂号
     *
     * @param registerId 挂号主键
     * @return 挂号
     */
    @Override
    public DoctorRegister selectDoctorRegisterByRegisterId(Long registerId)
    {
        return doctorRegisterMapper.selectDoctorRegisterByRegisterId(registerId);
    }

    /**
     * 查询挂号列表
     *
     * @param doctorRegister 挂号
     * @return 挂号
     */
    @Override
    public List<DoctorRegister> selectDoctorRegisterList(DoctorRegister doctorRegister)
    {
        return doctorRegisterMapper.selectDoctorRegisterList(doctorRegister);
    }

    /**
     * 新增挂号
     *
     * @param doctorRegister 挂号
     * @return 结果
     */
    @Override
    public int insertDoctorRegister(DoctorRegister doctorRegister)
    {
        doctorRegister.setCreateTime(DateUtils.getNowDate());
        return doctorRegisterMapper.insertDoctorRegister(doctorRegister);
    }

    /**
     * 修改挂号
     *
     * @param doctorRegister 挂号
     * @return 结果
     */
    @Override
    public int updateDoctorRegister(DoctorRegister doctorRegister)
    {
        doctorRegister.setUpdateTime(DateUtils.getNowDate());
        return doctorRegisterMapper.updateDoctorRegister(doctorRegister);
    }

    /**
     * 批量删除挂号
     *
     * @param registerIds 需要删除的挂号主键
     * @return 结果
     */
    @Override
    public int deleteDoctorRegisterByRegisterIds(Long[] registerIds)
    {
        return doctorRegisterMapper.deleteDoctorRegisterByRegisterIds(registerIds);
    }

    /**
     * 删除挂号信息
     *
     * @param registerId 挂号主键
     * @return 结果
     */
    @Override
    public int deleteDoctorRegisterByRegisterId(Long registerId)
    {
        return doctorRegisterMapper.deleteDoctorRegisterByRegisterId(registerId);
    }

    /**
     * 根据状态查询挂号
     * @param registerStatus
     * @return
     */
    @Override
    public List<DoctorRegister> selectListByRegisterStatus(Integer registerStatus) {
        return doctorRegisterMapper.selectListByRegisterStatus(registerStatus);
    }

    /**
     * 接诊，修改挂号状态为 就诊中 2
     * @param doctorRegister
     * @return
     */
    @Override
    public int updateTreatPatient(DoctorRegister doctorRegister) {
        //设置状态为 就诊中
        doctorRegister.setRegisterStatus("2");
        return doctorRegisterMapper.updateDoctorRegister(doctorRegister);
    }
}

